import axios from "axios";
import React from "react";
import { useLocation } from "react-router-dom";
import { Button } from "react-vant";
const id = new Date().getTime();
const title = "商品标题";
const Index = () => {
  const { state } = useLocation();
  const price = state.price;

  const pay = async () => {
    const resp = await axios.post("/api/pay", { price, title, id });
    console.log(resp.data);
		window.location.href = resp.data.data
  };
  return (
    <div>
      <div>订单编号：{id}</div>
      <div>订单标题：{title}</div>
      <div>订单总额：{price}</div>
      <Button type="primary" block round onClick={() => pay()}>
        下单
      </Button>
    </div>
  );
};

export default Index;
